package com.tianqu.tms.www.transfer.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.TransferWorkCount;
import com.tianqu.tms.www.transfer.viewhelper.TransferWorkCountViewHelper;

public class TransferWorkCountInputTopAction extends TmsAction {

	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		TransferWorkCountViewHelper view = (TransferWorkCountViewHelper)uc.getAttribute(TmsConstants.VIEWHELP);
		String countMonth = view.getCountMonth();
		String userId = view.getUserid();
		//根据月份查询列表信息
		TransferWorkCount entity = new TransferWorkCount();
		List<TransferWorkCount> list = entity.getWorkCountListByMonth(countMonth,userId);
		view.setWorkCountList(list);
		if(DateUtil.getCurrentTimeStr4().equals(countMonth) && view.getFlag()==1){
			view.setUpdateFlag(1);
		}else{
			view.setUpdateFlag(2);
		}
		request.setAttribute(TmsConstants.VIEWHELP, view);
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
